import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import Components from "unplugin-vue-components/vite";
import AutoImport from "unplugin-auto-import/vite";
export default defineConfig({

  server: {
    
    port: 8080,
    
    proxy: { 
      '/api': {
        target: 'http://192.168.233.129:8000',  //你要跨域访问的网址
        changeOrigin: true,   // 允许跨域
        rewrite: (path) => path.replace(/^\/api/, '') // 重写路径把路径变成空字符
      }
    }
  },
  plugins: [vue(), vueJsx(),    Components({
    // 指定组件位置，默认是 src/components
    dirs: ["src/components", "src/views"],
    // 搜索子目录
    deep: true,
    // 组件的有效文件扩展名
    extensions: ["vue"],
    // 配置文件生成位置
    dts: "components.d.ts",
  }),AutoImport({
    // 注册要自动引入的库
    imports: ["vue", "vue-router", "pinia", "@vueuse/core"],
   // 可以选择auto-import.d.ts生成的位置，使用ts建议设置为'src/auto-import.d.ts'
   dts: "auto-import.d.ts",
 }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
				additionalData: `@import "@/assets/styles/mixin.scss";`
			}
    },
  },

})


